<template>
  <!--历史病历列表 -->
  <div>
    <a-collapse v-if="dataSource.length > 0">
      <a-collapse-panel v-for="(list, listIndex) in dataSource" :key="listIndex">
        <template #header>
          <div class="flex justify-between">
            <div>{{ list?.brName }}</div>
            <div>{{ list?.itemName }}</div>
            <!-- <LabelValue class="mb-1" :value="list?.brName" />
            <LabelValue class="mb-1" :value="list?.itemName" /> -->
          </div>
          <LabelValue class="mb-3" :width="180" :title="list?.bcLczdZdmc" label="诊断" :value="list?.bcLczdZdmc" />
          <LabelValue class="mb-3" :width="200" label="登记时间" :value="list?.yyrq + ' ' + list?.yysj" />
          <LabelValue class="mb-3" :width="200" label="开始时间" :value="list?.startTime" />
          <LabelValue class="mb-3" :width="200" label="结束时间" :value="list?.endTime" />
          <LabelValue class="mb-3" :width="200" label="疗程记录" :value="list?.courseRecord" />
          <LabelValue class="mb-3" :width="200" label="疗程结果" :value="list?.courseResult" />
        </template>
        <div>
          <BaseTitle title="病历">
            <a-button :disabled="!list?.bcZs" type="primary" size="small" ghost @click="onCopy(list)">复制</a-button>
          </BaseTitle>
          <div>
            <LabelValue class="mb-3" :width="180" label="主诉" :value="list?.bcZs" />
            <LabelValue class="mb-3" :width="180" label="病史" :value="list?.bcXbs" />
            <LabelValue class="mb-3" :width="180" label="既往史" :value="list?.bcJws" />
            <LabelValue class="mb-3" :width="180" label="体格检查" :value="list?.bcTgjc" />
            <LabelValue class="mb-3" :width="180" label="辅助检查" :value="list?.bcFzjc" />
            <LabelValue class="mb-3" :width="180" label="初步诊断" :value="list?.bcLczdZdmc" />
            <LabelValue class="mb-3" :width="180" label="其他诊断" :value="list?.bcQtzdZdmc" />
            <LabelValue class="mb-3" :width="180" label="注意事项" :value="list?.bcZysx" />
            <LabelValue class="mb-3" :width="180" label="处置" :value="list?.bcCz" />
          </div>
        </div>
      </a-collapse-panel>
    </a-collapse>
    <a-empty v-else />
  </div>
</template>
<script setup>
import { ref, watchEffect } from 'vue'
import { message } from 'ant-design-vue'
import BaseTitle from '@/components/BaseTitle'
import LabelValue from '@/components/LabelValue'
import { post } from '@/utils/request'
import useStore from '../../store'

const store = useStore()
const dataSource = ref([])

const queryList = async () => {
  const res = await post('/course/courseProgressNotes/getCourseProgressHistory', {
    brId: store.currentPatient.brId
  })
  dataSource.value = res.data || []
}
watchEffect(() => {
  store.currentPatient.brId && queryList()
})

const onCopy = (list) => {
  store.tempCase = list
  message.success('复制病历成功')
}
</script>
